Flow.genXml = function(fo, faces){
	// pa：参数数组
	var ns = fo.nodes, pa = [];
	//
	function tabs(l){
		var t = "\t";
		for (var i=0; i<l; i++) {
			t += "\t";
		}
		return t;
	}
	//
	function genIt(n, l) {
		var xml = '';
		switch(n.t) {
		case 'arrow':
			xml += tabs(l) + genIt(n.n, l);
			return xml;
		case 'input':
		case 'output':
		case 'switch':
			xml += tabs(l) + '<!-- Do not support ' + n.t + ' -->' + "\n";
			xml += genIt(n.n.n, l);
			return xml;
		case 'end':
			xml += tabs(l) + '<dap:stop />' + "\n";
			return xml;
		case 'beginTx':
			xml += tabs(l) + '<dap:invoke';
			if (n.d.tran) {
				xml += ' transaction="' + Cache.base.flow.tran[n.d.tran] + '"';
			}
			n = n.n.n;
			var f = faces[n.d.faceId];
			xml += ' ref="' + n.d.code + '" method="' + f.entry+ '(' + n.d.code + 'Pms)"';
			xml += ' />' + "\n";
			return xml;
		case 'commitTx':
			xml += "\t" + '</dap:invoke>' + "\n";
			return xml;
		case 'start':
			xml += tabs(l) + '<dap:flow service-id="' + fo.d.code + '">' + "\n";
			xml += tabs(l+1) + '<dap:try>' + "\n";
			xml += genIt(n.n.n, l+2);
			xml += tabs(l+1) + '</dap:try>' + "\n";
			return xml;
		case 'process':
			var f = faces[n.d.faceId];
			xml += tabs(l) + '<dap:service ref="' + n.d.code + '" method="';
			xml += f.entry + '(' + n.d.code + '-P)" rev-ref="' + n.d.revRef;
			xml += '" rev-method="' + n.d.revMethod + '()"/>' + "\n";
			return xml;
		case 'judge':
			var b = {};
			for (var k in n.n) {
				var z = ns[k];
				b[z.d.tagCode] = z;
			}
			xml += tabs(l) + '<dap:if expression="' + n.d.exprCode + '">' + "\n";
			xml += genIt(b.yes.n, l+1);
			xml += tabs(l) + '</dap:if>' + "\n";
			xml += tabs(l) + '<dap:else>' + "\n";
			xml += genIt(b.no.n, l+1);
			xml += tabs(l) + '</dap:else>' + "\n";
			return xml;
		case 'catchStart':
			xml += tabs(l+1) + '<dap:catch>' + "\n";
			xml += genIt(n.n.n, l+2);
			xml += tabs(l+1) + '</dap:catch>' + "\n";
			return xml;
		case 'catchEnd':
			return xml;
		case 'finallyStart':
			xml += tabs(l+1) + '<dap:finally>' + "\n";
			xml += genIt(n.n.n, l+2);
			xml += tabs(l+1) + '</dap:finally>' + "\n";
			return xml;
		case 'finallyEnd':
			return xml;
		}
	}
	//
	var xml = '<?xml version="1.0" encoding="UTF-8"?>' + "\n"
		+ '<beans xmlns="http://www.springframework.org/schema/beans"' + "\n"
		+ ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' + "\n"
		+ ' xsi:schemaLocation="http://www.springframework.org/schema/beans' + "\n"
		+ '	http://www.springframework.org/schema/beans/spring-beans-3.2.xsd' + "\n"
		+ '	http://www.dap.com/schema/dap-flow' + "\n"
		+ '	http://www.dap.com/schema/dap-flow.xsd' + "\n\n";
	for (var i=1; i<ns.length; i++) {
		var n = ns[i];
		if (!n || !n.d || n.d.o) {
			continue;
		}
		if (!n.check()) {
			alert(Cache.base.flow.node[n.t].name
				+ ' ' + (n.d.name || n.m.caption) + ' 存在问题');
			return;
		}
		if (n.t == 'start' || n.t == 'catchStart' || n.t == 'finallyStart') {
			xml += genIt(n, 0);
		} else if (n.t == 'process') {
			pa.push(n);
		}
	}
	xml += tabs(0) + '</dap:flow>' + "\n\n";
	xml += tabs(0) + '<!-- Parameter POJOs -->' + "\n\n";
	for (var i in pa) {
		var n = pa[i];
		if (!n.pm) {
			continue;
		}
		xml += tabs(0) + '<bean id="' + n.d.code + '-P" parent="DEFAULT_PARAM">' + "\n";
		xml += tabs(1) + '<property name="returnClass" value="' + n.pm.belong + '"/>' + "\n";
		xml += tabs(1) + '<property name="mapping">' + "\n";
		xml += tabs(2) + '<props>' + "\n";
		for (var k in n.pm) {
			if (k == 'belong') {
				continue;
			}
			xml += tabs(3) + '<prop key="' + k + '">' + n.pm[k]  + '</prop>' + "\n";
		}
		xml += tabs(2) + '</props>' + "\n";
		xml += tabs(1) + '</property>' + "\n";
		xml += tabs(0) + '</bean>' + "\n\n";
	}
	xml += '</beans>' + "\n";
	return xml;
}